package com.ruoyi.person.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.person.model.LProject;
import com.ruoyi.person.model.Leader;
import com.ruoyi.person.service.ILeaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/leader")
public class LeaderController extends BaseController {

    @Autowired
    ILeaderService service;

    @GetMapping("/list")
    public TableDataInfo listAll(Leader leader){
        startPage();
        List<Leader> allLeader = service.getAllLeader(leader);
        return getDataTable(allLeader);
    }

    @GetMapping("/project/list")
    public TableDataInfo listProject(Leader leader){
        startPage();
        List<LProject> projects = service.getProjectsByLeaderId(leader.getUserId());
        return getDataTable(projects);
    }

}
